﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
using DelonixRegiaHotel.Classes;
using DelonixRegiaHotel.DBManager;
using System.Collections;
using System.Text.RegularExpressions;


namespace DelonixRegiaHotel
{
    public partial class CheckIn : Form
    {
        decimal extraCost = 0;
        ArrayList tempCreditCardInfo = new ArrayList();
        DateTime cardExpNo;
        string customerID;

        public CheckIn()
        {

            InitializeComponent();

            //Validate Integers TextBox
            this.tbxContactNo.KeyDown += new KeyEventHandler(tbxContactNo_KeyDown);
            this.tbxPostalCode.KeyDown += new KeyEventHandler(tbxPostalCode_KeyDown);
            this.tbxNumOfAdult.KeyDown += new KeyEventHandler(tbxNumOfAdult_KeyDown);
            this.tbxNumOfChild.KeyDown += new KeyEventHandler(tbxNumOfChild_KeyDown);
            this.tbxNumOfDay.KeyDown += new KeyEventHandler(tbxNumOfDay_KeyDown);
            this.tbxNoOfKeys.KeyDown += new KeyEventHandler(tbxNoOfKeys_KeyDown);
            this.tbxDOB.KeyDown += new KeyEventHandler(tbxDOB_KeyDown);
            this.tbxCardExpNo.KeyDown += new KeyEventHandler(tbxCardExpNo_KeyDown);
            this.tbxDeposit.KeyDown += new KeyEventHandler(tbxDeposit_KeyDown);
            //-----


            timer1.Start();
            cbxCardNo.Visible = false;
            tbxCardNo.Visible = false;
            labelCardExpNo.Visible = false;
            labelCardNumber.Visible = false;
            tbxCardExpNo.Visible = false;
            cbxCardNo.Visible = false;
            label29.Visible = false;
            cbxupdatecreditcard.Visible = false;
            List<string> countries = getCountryList();
            cbxCountry.DataSource = countries;
            ArrayList roomInfo = new ArrayList();
            string cuID = "CU" + DateTime.Now.GetHashCode();
            lblCustomerID.Text = cuID;
            
        
        }
            

      //Methods to validate integers textbox
        public void checkForIntNumber(object sender, KeyEventArgs e)
        {
            //Allow navigation keyboard arrows
            switch (e.KeyCode)
            {
                case Keys.Up:
                case Keys.Down:
                case Keys.Left:
                case Keys.Right:
                case Keys.PageUp:
                case Keys.PageDown:
                case Keys.Delete:
                case Keys.NumPad0:
                case Keys.NumPad1:
                case Keys.NumPad2:
                case Keys.NumPad3:
                case Keys.NumPad4:
                case Keys.NumPad5:
                case Keys.NumPad6:
                case Keys.NumPad7:
                case Keys.NumPad8:
                case Keys.NumPad9:

                    e.SuppressKeyPress = false;
                    return;
                default:
                    break;
            }

            //Block non-number characters
            char currentKey = (char)e.KeyCode;
            bool modifier = e.Control || e.Alt || e.Shift;
            bool nonNumber = char.IsLetter(currentKey) ||
                             char.IsSymbol(currentKey) ||
                             char.IsWhiteSpace(currentKey) ||
                             char.IsPunctuation(currentKey);

            if (!modifier && nonNumber)
                e.SuppressKeyPress = true;

            //Handle pasted Text
            if (e.Control && e.KeyCode == Keys.V)
            {
                //Preview paste data (removing non-number characters)
                string pasteText = Clipboard.GetText();
                string strippedText = "";
                for (int i = 0; i < pasteText.Length; i++)
                {
                    if (char.IsDigit(pasteText[i]))
                        strippedText += pasteText[i].ToString();
                }

                if (strippedText != pasteText)
                {
                    //There were non-numbers in the pasted text
                    e.SuppressKeyPress = true;

                    //OPTIONAL: Manually insert text stripped of non-numbers
                    TextBox me = (TextBox)sender;
                    int start = me.SelectionStart;
                    string newTxt = me.Text;
                    newTxt = newTxt.Remove(me.SelectionStart, me.SelectionLength); //remove highlighted text
                    newTxt = newTxt.Insert(me.SelectionStart, strippedText); //paste
                    me.Text = newTxt;
                    me.SelectionStart = start + strippedText.Length;
                }
                else
                    e.SuppressKeyPress = false;
            }
        } //generalized Method for validating int
        private void tbxContactNo_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        private void tbxPostalCode_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        private void tbxCardNo_KeyDown(object sender, KeyEventArgs e)

        {
            checkForIntNumber(sender, e);
        }
        private void tbxNoOfKeys_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        private void tbxNumOfDay_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        private void tbxNumOfChild_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        private void tbxNumOfAdult_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }



        //Method to validate Date textbox
        public void checkForDate(object sender, KeyEventArgs e)
        {
            //Allow navigation keyboard arrows
            switch (e.KeyCode)
            {
                case Keys.Up:
                case Keys.Down:
                case Keys.Left:
                case Keys.Right:
                case Keys.PageUp:
                case Keys.PageDown:
                case Keys.Delete:
                case Keys.NumPad0:
                case Keys.NumPad1:
                case Keys.NumPad2:
                case Keys.NumPad3:
                case Keys.NumPad4:
                case Keys.NumPad5:
                case Keys.NumPad6:
                case Keys.NumPad7:
                case Keys.NumPad8:
                case Keys.NumPad9:
                case Keys.OemMinus:
                case Keys.NumLock:

                    e.SuppressKeyPress = false;
                    return;
                default:
                    break;
            }

            //Block non-number characters
            char currentKey = (char)e.KeyCode;
            bool modifier = e.Control || e.Alt || e.Shift;
            bool nonNumber = char.IsLetter(currentKey) ||
                             char.IsSymbol(currentKey) ||
                             char.IsWhiteSpace(currentKey) ||
                             char.IsPunctuation(currentKey);

            if (!modifier && nonNumber)
                e.SuppressKeyPress = true;

            //Handle pasted Text
            if (e.Control && e.KeyCode == Keys.V)
            {
                //Preview paste data (removing non-number characters)
                string pasteText = Clipboard.GetText();
                string strippedText = "";
                for (int i = 0; i < pasteText.Length; i++)
                {
                    if (char.IsDigit(pasteText[i]))
                        strippedText += pasteText[i].ToString();
                }

                if (strippedText != pasteText)
                {
                    //There were non-numbers in the pasted text
                    e.SuppressKeyPress = true;

                    //OPTIONAL: Manually insert text stripped of non-numbers
                    TextBox me = (TextBox)sender;
                    int start = me.SelectionStart;
                    string newTxt = me.Text;
                    newTxt = newTxt.Remove(me.SelectionStart, me.SelectionLength); //remove highlighted text
                    newTxt = newTxt.Insert(me.SelectionStart, strippedText); //paste
                    me.Text = newTxt;
                    me.SelectionStart = start + strippedText.Length;
                }
                else
                    e.SuppressKeyPress = false;
            }
        }
        private void tbxDOB_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        private void tbxCardExpNo_KeyDown(object sender, KeyEventArgs e)
        {
            checkForIntNumber(sender, e);
        }
        //

        public void checkForDecimal(object sender, KeyEventArgs e)
        {
            //Allow navigation keyboard arrows
            switch (e.KeyCode)
            {
                case Keys.Up:
                case Keys.Down:
                case Keys.Left:
                case Keys.Right:
                case Keys.PageUp:
                case Keys.PageDown:
                case Keys.Delete:
                case Keys.NumPad0:
                case Keys.NumPad1:
                case Keys.NumPad2:
                case Keys.NumPad3:
                case Keys.NumPad4:
                case Keys.NumPad5:
                case Keys.NumPad6:
                case Keys.NumPad7:
                case Keys.NumPad8:
                case Keys.NumPad9:
                case Keys.Decimal:

                    e.SuppressKeyPress = false;
                    return;
                default:
                    break;
            }

            //Block non-number characters
            char currentKey = (char)e.KeyCode;
            bool modifier = e.Control || e.Alt || e.Shift;
            bool nonNumber = char.IsLetter(currentKey) ||
                             char.IsSymbol(currentKey) ||
                             char.IsWhiteSpace(currentKey) ||
                             char.IsPunctuation(currentKey);

            if (!modifier && nonNumber)
                e.SuppressKeyPress = true;

            //Handle pasted Text
            if (e.Control && e.KeyCode == Keys.V)
            {
                //Preview paste data (removing non-number characters)
                string pasteText = Clipboard.GetText();
                string strippedText = "";
                for (int i = 0; i < pasteText.Length; i++)
                {
                    if (char.IsDigit(pasteText[i]))
                        strippedText += pasteText[i].ToString();
                }

                if (strippedText != pasteText)
                {
                    //There were non-numbers in the pasted text
                    e.SuppressKeyPress = true;

                    //OPTIONAL: Manually insert text stripped of non-numbers
                    TextBox me = (TextBox)sender;
                    int start = me.SelectionStart;
                    string newTxt = me.Text;
                    newTxt = newTxt.Remove(me.SelectionStart, me.SelectionLength); //remove highlighted text
                    newTxt = newTxt.Insert(me.SelectionStart, strippedText); //paste
                    me.Text = newTxt;
                    me.SelectionStart = start + strippedText.Length;
                }
                else
                    e.SuppressKeyPress = false;
            }
        } //generalized Method for validating int
        private void tbxDeposit_KeyDown(object sender, KeyEventArgs e)
        {
            checkForDecimal(sender, e);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (lblCheckOut.Text =="-")
            {
                MessageBox.Show("Please ensure to select a checkout Date");
            }
            else
            {
                RoomAvailability popup = new RoomAvailability(Convert.ToInt32(tbxNumOfDay.Text), dateTimePicker1.Value.Date, Convert.ToDateTime(lblCheckOut.Text), this);

                popup.ShowDialog();
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            label24.Text = dt.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (tbxNumOfDay.Text != string.Empty)
            {
                int days = int.Parse(tbxNumOfDay.Text);
                DateTime date = DateTime.Now.AddDays(days);
                string day = dateTimePicker1.Value.AddDays(days).ToLongDateString();
                lblCheckOut.Text = day;
            }
            else
            {
                MessageBox.Show("Please enter a number", "Error! Empty Field");
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (tbxDeposit.Text == string.Empty)
            {
                MessageBox.Show("Please enter a value");
            }
            else
            {
                decimal deposit = Convert.ToDecimal(tbxDeposit.Text);
                decimal total = Convert.ToDecimal(lblTotal.Text);
                decimal balance = total - deposit;
                lblBalance.Text = Convert.ToString(balance);
            }
        }

        private void btnCheckIn_Click(object sender, EventArgs e)
        {
            DateTime temp;
            if (DateTime.TryParse(tbxDOB.Text, out temp))
            {
                tbxDOB.Text = temp.ToString(@"yyyy-MM-dd");
            }
            else
            {
                MessageBox.Show("Invalid Date Format");
            }


            string ckID = "CKID" + DateTime.Now.GetHashCode();

            bool checkForCustomerID = DelonixRegiaDB.CheckForCustomerID(lblCustomerID.Text);

            if (tbxFirstName.Text == string.Empty || tbxLastName.Text == string.Empty || tbxNRIC.Text == string.Empty || tbxAddress.Text == string.Empty || tbxPostalCode.Text == string.Empty || cbxCountry.SelectedIndex < 0 ||
                tbxDOB.Text == string.Empty || tbxContactNo.Text == string.Empty || tbxEmail.Text == string.Empty )
            {
                MessageBox.Show("Please ensure that all Customer information is filled up!", "Error! Missing information in Customer Section", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (tbxDeposit.Text == string.Empty || lblBalance.Text == "-" || lblCheckOut.Text == "-" || lblRmNum.Text == "-" || tbxNumOfAdult.Text == string.Empty || tbxNumOfChild.Text == string.Empty || tbxNoOfKeys.Text == string.Empty || lblRoomPrice.Text == "-")
            {
                MessageBox.Show("Please ensure that all CheckIn information is filled up!", "Error! Missing information in CheckIn's Information Section", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else // string not empty
            {

                if (checkForCustomerID == true)
                {
                    //update Customer

                    Customer cu = new Customer();
                    cu.CustomerID = lblCustomerID.Text;
                    cu.FirstName = tbxFirstName.Text;
                    cu.LastName = tbxLastName.Text;
                    cu.Nric = tbxNRIC.Text;
                    cu.HomeAddress = tbxAddress.Text;
                    cu.PostalCode = Convert.ToInt32(tbxPostalCode.Text);
                    cu.Country = cbxCountry.SelectedItem.ToString();
                    cu.Dob = Convert.ToDateTime(tbxDOB.Text);
                    cu.ContactNo = Convert.ToInt32(tbxContactNo.Text);
                    cu.Email = tbxEmail.Text;


                    CheckInOut cio = new CheckInOut();
                    cio.CheckID = ckID;
                    cio.CustomerID = lblCustomerID.Text;
                    cio.Deposit = Convert.ToDecimal(tbxDeposit.Text);
                    cio.Balance = Convert.ToDecimal(lblBalance.Text);
                    cio.ExtraCostTotal = extraCost;
                    CreditCardInfo cci = new CreditCardInfo();
                    if (rbcash.Checked)
                    {
                        cio.PaymentType = rbcash.Text.ToString();

                    }
                    else
                    {

                        cio.PaymentType = rbccard.Text.ToString();
                        if (tbxCardNo.Text != string.Empty || tbxCardExpNo.Text != string.Empty)
                        {
                            cci = new CreditCardInfo();
                            cci.CreditCardNo = Convert.ToInt64(tbxCardNo.Text);
                            cci.CreditCardExpDate = Convert.ToDateTime(tbxCardExpNo.Text);
                            cci.CustomerID = lblCustomerID.Text;
                            cci.CreditCardHolder = tbxFirstName.Text + " " + tbxLastName.Text;
                            DelonixRegiaDB.InsertCreditCardInfo(cci);
                        }
                        else
                        {
                            MessageBox.Show("Ensure that all Credit Card Details are filled Up", "Error! Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }


                    }

                    cio.CheckInTime = dateTimePicker1.Value.Date;
                    cio.CheckOutTime = Convert.ToDateTime(lblCheckOut.Text);
                    cio.RoomNo = lblRmNum.Text;
                    cio.Remarks = tbxRemark.Text;
                    cio.NumOfAdult = Convert.ToInt32(tbxNumOfAdult.Text);
                    cio.NumOfChild = Convert.ToInt32(tbxNumOfChild.Text);
                    cio.NumOfKey = Convert.ToInt32(tbxNoOfKeys.Text);
                    cio.RoomRate = Convert.ToDecimal(lblRoomPrice.Text);
                    cio.NumOfDays = Convert.ToInt32(tbxNumOfDay.Text);
                    
                    cio.RoomStatus = "CheckIn";

                    if (MessageBox.Show("Confirm CheckIn?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        if (DelonixRegiaDB.UpdateCustomer(cu) == 1 && DelonixRegiaDB.InsertCheckInDetails(cio) == 1)
                        {
                            MessageBox.Show("You have successfully check In", "Checked In!", MessageBoxButtons.OK);
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Please Ensure that all information are being entered!", "Error! Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {

                    Customer cu = new Customer();
                    cu.CustomerID = lblCustomerID.Text;
                    cu.FirstName = tbxFirstName.Text;
                    cu.LastName = tbxLastName.Text;
                    cu.Nric = tbxNRIC.Text;
                    cu.HomeAddress = tbxAddress.Text;
                    cu.PostalCode = Convert.ToInt32(tbxPostalCode.Text);
                   // cu.Country = cbxCountry.SelectedItem.ToString();
                    cu.Country = cbxCountry.Text;
                    cu.Dob = Convert.ToDateTime(tbxDOB.Text);
                    cu.ContactNo = Convert.ToInt32(tbxContactNo.Text);
                    cu.Email = tbxEmail.Text;


                    CheckInOut cio = new CheckInOut();
                    cio.CheckID = ckID;
                    cio.CustomerID = lblCustomerID.Text;
                    cio.Deposit = Convert.ToDecimal(tbxDeposit.Text);
                    cio.Balance = Convert.ToDecimal(lblBalance.Text);
                    cio.ExtraCostTotal = extraCost;
                    CreditCardInfo cci = new CreditCardInfo();
                    if (rbcash.Checked)
                    {
                        cio.PaymentType = rbcash.Text.ToString();

                    }
                    else
                    {

                        cio.PaymentType = rbccard.Text.ToString();
                        if (tbxCardNo.Text != string.Empty || tbxCardExpNo.Text != string.Empty)
                        {
                            cci = new CreditCardInfo();
                            cci.CreditCardNo = Convert.ToInt64(tbxCardNo.Text);
                            cci.CreditCardExpDate = Convert.ToDateTime(tbxCardExpNo.Text);
                            cci.CustomerID = lblCustomerID.Text;
                            cci.CreditCardHolder = tbxFirstName.Text + " " + tbxLastName.Text;
                        }
                        else
                        {
                            MessageBox.Show("Ensure that all Credit Card Details are filled Up", "Error! Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }


                    }

                    cio.CheckInTime = dateTimePicker1.Value.Date;
                    cio.CheckOutTime = Convert.ToDateTime(lblCheckOut.Text);
                    cio.RoomNo = lblRmNum.Text;
                    cio.Remarks = tbxRemark.Text;
                    cio.NumOfAdult = Convert.ToInt32(tbxNumOfAdult.Text);
                    cio.NumOfChild = Convert.ToInt32(tbxNumOfChild.Text);
                    cio.NumOfKey = Convert.ToInt32(tbxNoOfKeys.Text);
                    cio.RoomRate = Convert.ToDecimal(lblRoomPrice.Text);
                    cio.RoomStatus = "CheckIn";

                    if (MessageBox.Show("Confirm CheckIn?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        if (DelonixRegiaDB.InsertCustomer(cu) == 1 && DelonixRegiaDB.InsertCheckInDetails(cio) == 1)
                        {
                            MessageBox.Show("You have successfully check In", "Checked In!", MessageBoxButtons.OK);
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Please Ensure that all information are being entered!", "Error! Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }


                } //else bool check = false
            }  //else if string are not null
        }



        private void rbcash_CheckedChanged(object sender, EventArgs e)
        {
            labelCardExpNo.Visible = false;
            labelCardNumber.Visible = false;
            tbxCardExpNo.Visible = false;
            tbxCardNo.Visible = false;
            cbxCardNo.Visible = false;
            label29.Visible = false;
            cbxupdatecreditcard.Visible = false;
        }

        private void rbccard_CheckedChanged(object sender, EventArgs e)
        {
            tbxCardNo.Visible = true;
            labelCardExpNo.Visible = true;
            labelCardNumber.Visible = true;
            tbxCardExpNo.Visible = true;
            tbxCardNo.Visible = true;
            label29.Visible = true;
            cbxupdatecreditcard.Visible = true;
        }

        public List<string> getCountryList()
        {
            List<string> cultureList = new List<string>();
            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);

            cultureList.Add("-- Select Country --");

            foreach (CultureInfo culture in cultures)
            {
                CultureTypes ct = culture.CultureTypes;
                String s = ct.ToString();
                if (!s.Contains("NeutralCultures"))
                {
                    // check if it's not a invariant culture
                    if (culture.LCID != 127)
                    {
                        RegionInfo region = new RegionInfo(culture.LCID);
                        // add countries that are not in the list
                        if (!(cultureList.Contains(region.EnglishName)))
                        {
                            cultureList.Add(region.EnglishName);
                        }
                    }
                }
            }
            cultureList.Sort(); // sort alphabetically
            return cultureList;
        }

        private void btnNRIC_Click(object sender, EventArgs e)
        {

            bool check = DelonixRegiaDB.CheckForCustomerNric(tbxCheckNRIC.Text);


            if (tbxCheckNRIC.Text == string.Empty)
            {
                MessageBox.Show("Please enter an NRIC", "Error! Please enter an NRIC", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            if (check == false)
            {
                
                MessageBox.Show("No such customer found", "Error! Invalid NRIC", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {

                Customer c = DelonixRegiaDB.getCustomerDetails(tbxCheckNRIC.Text);
                lblCustomerID.Text = c.CustomerID;
                tbxFirstName.Text = c.FirstName;
                tbxLastName.Text = c.LastName;
                tbxNRIC.Text = c.Nric;
                tbxAddress.Text = c.HomeAddress;
                tbxPostalCode.Text = Convert.ToString(c.PostalCode);
                cbxCountry.Text = c.Country;
                tbxDOB.Text = Convert.ToString(c.Dob.ToShortDateString());
                tbxContactNo.Text = Convert.ToString(c.ContactNo);
                tbxEmail.Text = c.Email;

           //     CreditCardInfo cci = DelonixRegiaDB.getCustomerCardInfo(c.CustomerID);
        //        tbxCardExpNo.Text = Convert.ToString(cci.CreditCardExpDate.ToShortDateString());
                if (ManageCustomerDBManager.GetCreditInfoByCustomerId(c.CustomerID).Count > 0)
                {
                    
                    cbxCardNo.Visible = true;
                    tempCreditCardInfo = ManageCustomerDBManager.GetCreditInfoByCustomerId(c.CustomerID);

              //      cbxCardNo.Items.Add("-Select Card-");
                    foreach (CreditCardInfo cCardInfo in tempCreditCardInfo)
                    {
                        cbxCardNo.Items.Add(cCardInfo.CreditCardNo);
                        customerID = cCardInfo.CustomerID;
                    }
                    cbxCardNo.SelectedIndex = 0;
                    return;

                }
           //     tbxCardNo.Text = Convert.ToString(cci.CreditCardNo);

               
                
            }


        } //working

        private void btnCheckDOB_Click(object sender, EventArgs e)
        {
            DateTime temp;
            if (DateTime.TryParse(tbxDOB.Text, out temp))
            {
                tbxDOB.Text = temp.ToString(@"yyyy-MM-dd");

                MessageBox.Show("Valid Date");
            }
            else
            {
                MessageBox.Show("Invalid Date");
            }

        }

        private void cbxCardNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            tbxCardNo.Text = cbxCardNo.Text;

            CreditCardInfo cci = DelonixRegiaDB.getCustomerCardInfo(Convert.ToInt64(cbxCardNo.SelectedItem));
            tbxCardExpNo.Text = cci.CreditCardExpDate.ToShortDateString();
        }

        //public static string ReplaceAt(this string input, int index, char newChar)
        //{
        //    if (input == null)
        //    {
        //        throw new ArgumentNullException("input");
        //    }
        //    char[] chars = input.ToCharArray();
        //    chars[index] = newChar;
        //    return new string(chars);
        //}

    }
}
